2 Problem: 10573 - Geometry Paradox (UVa)
25 #define foreach(x, v) for (typeof (v).begin() x = (v).begin(); x != (v).end(); ++x)
26 #define D(x) cout << #x " is " << x << endl
27 #define For(i, a, b) for (int i=(a); i<(b); ++i)
34 while (n
-- && getline(cin
, s
)){
36 if (sscanf(s
.c_str(), "%d %d", &r1
, &r2
) == 2){
37 printf("%.4lf\n", 4*acos(0)*r1
*r2
);
40 sscanf(s
.c_str(), "%d", &t
);
41 printf("%.4lf\n", acos(0)*t
*t
/4);
48 If you are given r1 and r2, then the gray area is
49 the area of the big circle minus the area of the small circles:
51 pi * ((r1 + r1)² - r1² - r2²)) = 2 * pi * r1 * r2
53 If you are given t, you can form a rectangular triangle where the cathetuses
54 are (t/2) and k, and the hypothenuse is (r1 + r2). Then, k = (r1 - r2).
55 Solve the pythagorean theorem for this triangle and you should get
59 Replace r1 * r2 in the formula above and you will get
60 2 * pi * r1 * r2 = 2 * pi * (t² / 16) = pi * t² / 8